package com.dragon.array;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

/**
 * ArrayList集合的测试方法
 *
 * @author dragon
 * @version V1.0.0-RELEASE
 * @date 2019/5/10 19:38
 */
public class ArrayListTest {

    public static void main(String[] args) {
        // 创建一个集合
        List<Integer> list = Arrays.asList(1, 2, 3, 4);
        // 将集合转为数组
        Integer[] array = list.toArray(new Integer[list.size()]);
        // 打印数组元素
        System.out.println(Arrays.toString(array));


        ArrayList<Object> objects = new ArrayList<>();

        Iterator<Object> iterator = objects.iterator();

        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}
